<template>
<div class="bg-white">
  <!--<ClassInfo @changeXkkh="changeXkkh" @hasClass="hasClass" userIdentity="Student"  barButton="!disable" ></ClassInfo>-->
  <ClassInfo  @hasClass="hasClass" @passInfo="passInfo"   barButton="!disable" ></ClassInfo>
  <mu-toast v-if="toast" message="保存成功!" @close="hideToast"/>
  
  <mu-list v-show="!noClass" >
    <!--<mu-sub-header >
				课堂日志
    </mu-sub-header>-->
    <section class="diary-title">
    		<span class="diary-title-left">课堂日志</span>
    		<span class="diary_state" :class="FnDiaSta()">{{subState}}</span>
    </section>
      <!--<mu-divider />
        <mu-list-item disableRipple>
        <mu-icon  value="alarm"  color="blue"/>
        <mu-time-picker v-model="DDSJ" :disabled="disable||!enable" helpText="到达时间" hintText="到达时间" format="24hr" />
        <br/>
        <mu-icon value="alarm"  color="blue"/>
        <mu-time-picker v-model="LKSJ" :disabled="disable||!enable" helpText="离开时间" hintText="离开时间" format="24hr" />
        
      </mu-list-item>
     <mu-divider />-->
      
      <!--<mu-list-item disableRipple :title="'讲授时长:'+JSSJ+'分钟'"  >
       <mu-icon slot="left" value="alarm"  color="blue"/>
      </mu-list-item>
      
      <div class="mu-list-item-zzg">
        <mu-slider :disabled="disable||!enable" v-model="JSSJ" :step="1" :max="SKSC" class="demo-slider"/>
      </div>-->
      
      <!---授课类型下拉框测试版-->
      <!--<mu-select-field style="margin-left: 1.5rem;width: 50%;" v-model="teachTypeChoice"  label="选择你的授课类型">
		    <mu-menu-item v-for="text,index in teachTypeList" :key="index" :value="index" :title="text" />
		  </mu-select-field>-->
		  
		  
		  <mu-list-item @click="isTeachType=true" >
        <mu-icon slot="left" value="class"  color="blue"/>
        <span style="font-size: 1rem;">授课类型：{{teachTypeSub}}</span>
        <mu-icon slot="right" value="keyboard_arrow_right" color="blue" />
      </mu-list-item>
		  
      <mu-list-item title="" >
      	<mu-icon slot="left" value="alarm"  color="blue"/>
      	<span  style="font-size: 1rem;">到达时间:{{DDSJ}}</span>
      	 <yd-datetime type="time" v-model="DDSJ">
         </yd-datetime>
        <mu-icon slot="right" value="keyboard_arrow_right" color="blue" />
      </mu-list-item> 
      
      <mu-list-item title="" >
      	<mu-icon slot="left" value="alarm"  color="blue"/>
      	<span  style="font-size: 1rem;">离开时间:{{LKSJ}}</span>
      	 <yd-datetime type="time" v-model="LKSJ">
         </yd-datetime>
        <mu-icon slot="right" value="keyboard_arrow_right" color="blue" />
      </mu-list-item> 
      
      <mu-list-item title="" @click="openTimePop()">
         <mu-icon slot="left" value="alarm"  color="blue"/>
         <!--<span style="font-size: 1rem;">讲授时长:{{address[0]}}</span>-->
         <span style="font-size: 1rem;">讲授时长:{{timeLength[0]}}</span>
         <mu-icon slot="right" value="keyboard_arrow_right" color="blue" />
      </mu-list-item> 
      
      
    <section v-show="bottomPopup" class="temp-mask" @click="closeTimePop(beforeVal)">
    	
    </section>
    
    <yd-popup v-model="bottomPopup" position="bottom" :close-on-masker="false">
    		<div class="demo-picker-container" >
	        	<section class="slider-time" >
	        		<a @click="closeTimePop(beforeVal)">取消</a>
	        		<a style="color: #2397f2" @click="closeTimeSure()">确定</a>
	        	</section>
					  <mt-picker v-if="bottomPopup" :slots="slots" :visibleItemCount="7" @change="onValuesChange"></mt-picker>
					</div>
    </yd-popup>
      
      
  		<!--<mu-popup position="bottom" popupClass="demo-popup-bottom" :open="bottomPopup" @close="closeTimePop(beforeVal)">
    		<mu-content-block>
	        <div class="demo-picker-container" >
	        	<section class="slider-time" >
	        		<a @click="closeTimePop(beforeVal)">取消</a>
	        		<a style="color: #2397f2" @click="closeTimeSure()">确定</a>
	        	</section>
					  <mu-picker :slots="addressSlots" :visible-item-count="7" @change="addressChange" :values="address"/>
					</div>
				</mu-content-block>
			</mu-popup>-->
      
      
      <mu-divider />
      <mu-list-item @click="handleToggle('SFTG')" title="正常出勤">
        <mu-switch v-model="SFTG" :disabled="disable||!enable" slot="right"/>
        <mu-icon slot="left" value="alarm_on"  color="green500"/>
      </mu-list-item>
      <mu-divider />
      <mu-list-item @click="handleToggle('ZYBZ')" title="布置作业">
        <mu-icon slot="left" value="note_add"  color="green500"/>
        <mu-switch v-model="ZYBZ" :disabled="disable||!enable" slot="right"/>
      </mu-list-item>
      <mu-divider />
      <mu-list-item @click="handleToggle('SFKQ')" title="已考勤">
        <mu-icon slot="left" value="assignment_turned_in"  color="green500"/>
        <mu-switch v-model="SFKQ" :disabled="disable||!enable" slot="right"/>
      </mu-list-item>
      <mu-list-item @click="handleToggle('isMatch')" title="是否相符">
        <mu-icon slot="left" value="assignment_turned_in"  color="green500"/>
        <mu-switch v-model="isMatch" :disabled="disable||!enable" slot="right"/>
      </mu-list-item>
      
      
      
		  <mu-dialog  :open="isTeachType" @close="isTeachType=false"  scrollable>
         <mu-list>
          <section  style="display: flex;justify-content: center;font-size: 1rem;color: #000; position: relative; top: -0.7rem;">授课类型</section>
          <mu-list-item disableRipple title="A、理论课">
            <mu-radio slot="right" name="group" nativeValue="理论课" v-model="teachTypeSub"  class="demo-radio"/>
          </mu-list-item>
          <mu-list-item disableRipple title="B、理论和实践课">
            <mu-radio slot="right" name="group" nativeValue="理论和实践课" v-model="teachTypeSub"  class="demo-radio"/>
          </mu-list-item>
          <mu-list-item disableRipple title="C、实践课">
            <mu-radio slot="right" name="group" nativeValue="实践课" v-model="teachTypeSub"  class="demo-radio"/>
          </mu-list-item>
        </mu-list>
          <mu-raised-button label="确定" primary fullWidth @click="getTeachType()"/>
     </mu-dialog>
      
      
      
      <mu-list-item @click="openEdit" title="授课内容">
        <mu-icon slot="left" value="turned_in"  color="blue"/>
        <mu-icon slot="right" value="keyboard_arrow_right" color="blue" />
        <!--<span slot="right" style="color: blue;">编辑</span>-->
      </mu-list-item>
      <section>
      	<p style="width: 90%;margin:0 5%;padding: 0.5rem;font-size: 0.8rem;">
      		{{showContent}}
      	</p>
      </section>
      
      <mu-dialog :open="isEditTeach" title="编辑授课内容" @close="close">
		    	<section style="position: relative; height: 8.4rem;background-color: #fff;">
						<textarea class="remove-texStyle" placeholder="请输入授课内容(不少于10个字)" v-model="EditContent"></textarea>
						<aside class="Edit-count" >
							<span>{{EditContent.length}}</span>
							<span style="color: #b7b7b7;">/300</span>
						</aside>
					</section>
			    <mu-flat-button slot="actions" @click="closeEdit('cancel')" primary label="取消"/>
			    <mu-flat-button slot="actions" primary @click="closeEdit('sure')" label="确定"/>
		  </mu-dialog>
      
      
      
    </mu-list>
    
     <div v-show="!disable||!enable" style="margin-bottom: 3rem;">
        <mu-flexbox class="mt8" orient="vertical" v-if="false">
          <mu-flexbox-item order="2" class="flex-title">
            {{sknr.ktbh}}讲授内容
          </mu-flexbox-item>
          <mu-flexbox-item order="2" class="flex-body">
          {{sknr.nrxq}}
          </mu-flexbox-item>
        </mu-flexbox>
        <mu-divider />
        <!--<mu-flexbox class="mt8">
          <mu-flexbox-item class="flex-demo">
             <mu-flat-button label="上一节" @click="prev" class="demo-raised-button" primary/>
          </mu-flexbox-item>
          <mu-flexbox-item class="flex-demo">
             <mu-flat-button label="下一节" @click="next" class="demo-raised-button" primary/>
          </mu-flexbox-item>
        </mu-flexbox>-->

     </div>
  <mu-bottom-nav @change="handleChange" class="bottom-btnbar" v-show="isbotBtn">
    <mu-bottom-nav-item value="change" title="调停课" icon="refresh"/>
    <mu-bottom-nav-item value="save" title="提交" icon="save" v-show="enable"/>
    <mu-bottom-nav-item value="edit" title="修改" icon="edit" v-show="!enable"/>
  </mu-bottom-nav>
  <mu-bottom-nav @change="zengkeFn" class="bottom-btnbar" v-if="!isbotBtn">
    <mu-bottom-nav-item value="zk" title="增课" icon="add"/>
  </mu-bottom-nav>
  <mu-dialog :open="popCommissary" :title="popTitleInfo" @close="close">
    <mu-flat-button slot="actions" @click="close('cancel')" primary label="取消"/>
    <mu-flat-button slot="actions" primary @click="close('sure')" label="确定"/>
  </mu-dialog>
  <mu-dialog :open="popIsTime" :title="popIsTimeTitle" @close="close">
    <mu-flat-button slot="actions" primary @click="close('TimeCorrect')" label="确定"/>
  </mu-dialog>
  <mu-dialog :open="popIsAdd" :title="popIsAddTitle" @close="close">
    <!--<mu-flat-button slot="actions" @click="close('add')" primary label="取消"/>-->
    <mu-flat-button slot="actions" primary @click="close('add')" label="确定"/>
  </mu-dialog>
  
    <mu-dialog  :open="dialog" @close="dialog=false"  scrollable>
         <mu-list>
          <section  style="display: flex;justify-content: center;font-size: 1rem;color: #000; position: relative; top: -0.7rem;">类型选择</section>
          <mu-list-item disableRipple title="调课">
            <mu-radio slot="right" name="group" nativeValue="tiaoke" v-model="ttklx"  class="demo-radio"/>
          </mu-list-item>
           <mu-list-item disableRipple  title="增课">
            <mu-radio slot="right" name="group" nativeValue="zengke" v-model="ttklx" class="demo-radio"/>
          </mu-list-item>
          <mu-list-item disableRipple  title="自习">
            <mu-radio slot="right" name="group" nativeValue="zixi" v-model="ttklx" class="demo-radio"/>
          </mu-list-item>
          <mu-list-item disableRipple  title="停课">
            <mu-radio slot="right" name="group" nativeValue="ceaseClass" v-model="ttklx" class="demo-radio"/>
          </mu-list-item>
        </mu-list>
          <mu-raised-button label="确定" primary fullWidth @click="tiaotingkeHandle"/>
     </mu-dialog>
     
     
<!--</mu-paper>-->
					<!--<mu-toast v-if="toast" :message="message" />-->
  </div>
</template>
<script>
	
	
import ClassInfo from '@/components/class_info'
import axios from 'axios'
//import store from '../store/store'

export default {
  data () {
    return {
    	show2:false,
      saveStatic:'save',
      ttklx:'',
      dialog:false,
      popCommissary:false,
      popIsAdd:false,
      isCeaseClass:false,
      isSubmitThis:false,
      isZixi:false,
      popTitleInfo:'',
      popIsAddTitle:'',
      timeLong:0,
      SFTG:true, //是否脱岗
      DDSJ:'', //到达时间
      LKSJ:'', //离开时间
      JSSJ:0, //讲授时间
      ZYBZ:true, //作业布置
      SFKQ:true,  //是否考勤
      disable:true,
      enable:false,
      noClass:true,
      toast:false,
      SKSC:0,
      courseId:'',
      nrbm:'',
      ktxq:{},
      saveType:'save',
      allParameters:{},
      sknrList:[],
      sknrIndex:-1,
      isbotBtn:false,
      classTimeTable:{},
		  courseData:{},
		  todayCourse:{},
		  publicInfo:{
	    	academic:'',
	    	semester:'',
	    	teachWeek:''
		  },
		  currentTime:'',
		  currentmonth:'',
		  currentFullDate:'',
		  courIndex:'',
		  timeOption:{},
		  arrTime:0,
		  leaTime:0,
		  popIsTime:false,
		  popIsTimeTitle:'',
		  datetime1:'',
		  addressSlots: [
        {
          width: '100%',
          textAlign: 'center',
//        values: Object.keys(address),
					values:[]
        }, 
//      {
//        width: '100%',
//        textAlign: 'center',
//        values: ['0']
//      }
      ],
      address:[],
      beforeVal:[],
//    addressProvince: '北京',
//    addressCity: '北京',
      isMove:false,
      isFade:false,
      bottomPopup: false,
			slots: [
		    {
		      flex: 1,
		      values: [],
		      className: 'slot1',
		      textAlign: 'center',
		      defaultIndex:0,
		    }, 
		  ],
		  timeLength:[],
		  timeSure:false,
		  isEditTeach:false,
		  EditContent:'',
		  showContent:'',
		  diaryState:0,
		  subState:'',
		  isEditSec:true,
		  teachTypeChoice:0,
		  teachTypeSub:'',
		  teachTypeList: ['理论课', '理论和实践课', '实践课'],
		  isTeachType:false,
		  isMatch:true
    }
  },computed:{
    sknr:function(){
      if(this.sknrIndex>-1){
      return {nrxq:this.sknrList[this.sknrIndex].JXNR||'暂无安排',
              nrbm:this.sknrList[this.sknrIndex].NRBM,
              ktbh:'第'+parseInt(this.sknrList[this.sknrIndex].NRBM.substring(50))+'节，'
            }
      }
      else{
       return {nrxq:'暂无安排',
              nrbm:'',
              ktbh:''}
      }
    }
  },components:{
    ClassInfo
  },
  watch:{
  	DDSJ(newVal,oldVal){
    	this.arrTime=parseInt(newVal.replace(':',''))
    },
    LKSJ(newVal,oldVal){
    	this.leaTime=parseInt(newVal.replace(':',''))
    },
    address(newVal,oldVal){
//  	console.info(typeof parseInt(newVal[0]))
    },
    EditContent(newVal,oldVal){
    	if(newVal.length>300){
				this.EditContent=this.EditContent.slice(0,300)
			}
    },
    teachTypeChoice(newVal,oldVal){
//  	console.info(this.teachTypeChoice)
    }
  },
  mounted(){
//	this.getClassDiary()
  	this.variousTime()
    this.loadCoureInfo()
    let that=this
//  let time = setInterval(()=>{
//    let kqsj=that.ktxq["SJ"].replace(/-/g,'/')
//    //点名时间计算开始
//    let classStart = new Date(kqsj+" "+that.allParameters[that.ktxq["DJJ"]+"_class_start"]).getTime()
//    let classEnd = new Date(kqsj+" "+that.allParameters[(parseInt(that.ktxq["DJJ"])+parseInt(that.ktxq["SKCD"])-1)+"_class_end"]).getTime()
//    let beforeTime = parseInt(that.allParameters["roll_call_before_start"])*60000
//    let afterTime = parseInt(that.allParameters["roll_call_after_end"])*60000
//    classStart -=beforeTime
//    classEnd +=afterTime
//    //点名时间计算完成
//    //课堂日志截止时间
//    let commissary_log_end = new Date(kqsj+" "+that.allParameters["commissary_log_end"]).getTime()
//    //学生评教截止时间
//    let student_evaluate_end = new Date(kqsj+" "+that.allParameters["student_evaluate_end"]).getTime()
//    //教师评学截至时间
//    let teacher_evaluate_end = new Date(kqsj+" "+that.allParameters["teacher_evaluate_end"]).getTime()
//    let teacher_evaluate_open = that.allParameters["teacher_evaluate_open"]
//    let student_evaluate_open = that.allParameters["student_evaluate_open"]
//    let nT = new Date()
//    let timeNow = nT.getTime()
//    if(timeNow>classStart && timeNow<commissary_log_end){
//      that.disable=false
//    }else{
//      that.disable=true
//    }
//    //console.info(endTime);
//  },1000)
			this.loadBeforeCoure()
  },
  methods: {
  	getTeachType(){
  		if(this.teachTypeSub=='理论课'){
  				this.teachTypeChoice=0
  		}else if(this.teachTypeSub=='理论和实践课'){
  				this.teachTypeChoice=1
  		}else if(this.teachTypeSub=='实践课'){
  				this.teachTypeChoice=2
  		}
//		console.info(this.teachTypeChoice)
  		this.isTeachType=false
  	},
  	FnDiaSta(){
  		if(this.diaryState==0){
  			 this.subState='未提交'
  			 return 'diary_unsubmit' 
  		}else if(this.diaryState==1){
  			 this.subState='已提交'
  			 return 'diary_submit'
  		}else if(this.diaryState==2){
  			 this.subState='已修改'
  			 this.isEditSec=false
  			 return 'diary_edit'
  		}
  	},
  	openEdit(){
  		 this.isEditTeach=true
  	},
  	closeEdit(val){
  		if(val=='sure'){
  			this.showContent=this.EditContent
  		}
  		 this.isEditTeach=false
  	},
  	loadBeforeCoure(){
  			let that = this
  			//获取当天课程信息
	      	that.axios.get('iyx/course/'+localStorage.classId+'/ClassDiaryDayCourse').then(function (response) {
	      	}).catch(function (error) {
	        	console.log(error);
	      	});
  		},
  	openTimePop (position) {
      this.bottomPopup= true
    },
    onValuesChange(picker, values) {
//    if (values[0] > values[1]) {
//      picker.setSlotValue(1, values[0]);
//    }
			this.timeLength=values
			
			
    },
//  close2 (position) {
//    this[position + 'Popup'] = false
//  },
    closeTimePop(val){
//  	this.address=val
//  	this.beforeVal=val
			this.timeLength=this.beforeVal
			this.slots[0].defaultIndex=parseInt(this.beforeVal[0])
    	this.bottomPopup=false
    },
    closeTimeSure(){
//  	this.beforeVal=this.address
			this.timeSure=true
			this.slots[0].defaultIndex=parseInt(this.timeLength[0])
			this.beforeVal=this.timeLength
    	this.bottomPopup=false
    },
		addressChange (value, index) {
//    switch (index) {
//      case 0:
//        this.addressProvince = value
//        const arr = address[value]
//        this.addressSlots[1].values = arr
//        this.addressCity = arr[0]
//        break
//      case 1:
//        this.addressCity = value
//        break
//    }
//    this.address = [value]
   },
    //获取每节课的配置参数
    getCourTimeInfo(val){
			let that=this
			that.axios.get('/iyx/schedule/SelectAll').then(function(response){
				for(var i in response.data){
					that.timeOption[(parseInt(i)+1)+'']=response.data[i]
				}
//				console.info(that.timeOption)
				if(val.length==3){
						that.DDSJ=that.timeOption[val.slice(0,1)].start
						that.LKSJ=that.timeOption[val.slice(2)].end
						that.JSSJ=parseInt(that.timeOption[val.slice(0,1)].length)+parseInt(that.timeOption[val.slice(2)].length)
				}else if(val.length==4){
						that.DDSJ=that.timeOption[val.slice(0,1)].start
						that.LKSJ=that.timeOption[val.slice(2)].end
						that.JSSJ=parseInt(that.timeOption[val.slice(0,1)].length)+parseInt(that.timeOption[val.slice(2)].length)
				}else if(val.length==5){
						that.DDSJ=that.timeOption[val.slice(0,2)].start
						that.LKSJ=that.timeOption[val.slice(3)].end
						that.JSSJ=parseInt(that.timeOption[val.slice(0,2)].length)+parseInt(that.timeOption[val.slice(3)].length)
				}
				for(var i=0;i<that.JSSJ+20+1;i++){
						that.addressSlots[0].values.push((i)+'分钟')
						that.slots[0].values.push((i)+'分钟')
				}
				that.slots[0].defaultIndex=that.JSSJ
				that.timeLength=[that.JSSJ+'分钟']
//				that.address = [that.JSSJ+'分钟']
				that.beforeVal=[that.JSSJ+'分钟']
				that.SKSC=that.JSSJ
				if(that.DDSJ.length==4){
						that.DDSJ=0+that.DDSJ
				}
				if(that.LKSJ.length==4){
						that.LKSJ=0+that.LKSJ
				}
			}).catch(function(error){
				
			})
		},
  	//获取一天中的各种时间
    variousTime(){
    	var thisDate=new Date()
		  var currentYear=thisDate.getFullYear()
	  	var mon=this.correcTime(thisDate.getMonth()+1)       
	  	var toDate=this.correcTime(thisDate.getDate())
	  	var currentHour=this.correcTime(thisDate.getHours()) 
	  	var currentMinutes=this.correcTime(thisDate.getMinutes())
	  	
			this.currentmonth=mon+'-'+toDate
	  	this.currentTime=currentHour+':'+currentMinutes
	  	this.currentFullDate=currentYear+'-'+this.currentmonth
    },
    correcTime(data){
    	if(data<10){
    		data='0'+data
    	}
    	return data
    },
    //获取该班当天课程信息
  	loadCoureInfo(){
  			let that = this
  			//先改具体日期测试用that.currentFullDate
	      	that.axios.get('iyx/course/'+that.currentFullDate+'/'+localStorage.classId+'/ClassDayCourse').then(function (response) {
	        	if(response.data.length>0){
	        		that.todayCourse=response.data
	        	}else{
	        	}
	        	that.compile=true
	      	}).catch(function (error) {
	        	console.log(error);
	      	});
  	},
  	passInfo(val){
  		this.courseData=val
  		this.diaryState=val.courseDiaryState
  		console.info(this.courseData)
  		if(val.courseDiaryState==0){
  			  this.diaryState=0
  		}
  		this.isEditSec=true
  		let that=this
  		that.courseId=val.class_course_id
  		that.courIndex=val.courseWhichIndex+'-'+(parseInt(val.courseWhichIndex)+1)
  		this.getCourTimeInfo(that.courIndex)
  		that.axios.get('/iyx/diary/'+that.courseId+'/FindDiary?token='+localStorage.token).then(function(response){
  			if(response.data.length==0){
  			}
  		}).catch(function(error){
  		})
  		this.disable=false
  		this.enable=true
  	},
  	save2(val){
    	let that=this
    	that.variousTime()
//  	console.info(that.courseData.courseTeacherName)
    	that.axios.post('/iyx/diary/ClassDiary',{
    		"courseId":that.courseData.classCourseId,
    		"courseName": that.courseData.courseName,
			  "courseTeacherName": that.courseData.courseTeacherName,
			  "coursePosition":  that.courseData.courseClassroomPosition,
			  "courseIndex": that.courseData.courseWhichIndex+'-'+(parseInt(that.courseData.courseWhichIndex)+1),
			  "diaryState": val,
			  "diaryPostTime": that.currentFullDate+'-'+that.currentTime,
//			  "diary_revise_time": null,
			  "arriveTime": that.currentFullDate+'-'+that.DDSJ,
			  "leaveTime": that.currentFullDate+'-'+that.LKSJ,
			  "teachLength":parseInt(that.timeLength[0]),
			  "attendanceState":that.SFTG,
			  "homeworkState": that.ZYBZ,
			  "attcheckState":that.SFKQ,
			  "teachContent": that.showContent,
			  "teachingType":that.teachTypeChoice,
			  "isMatchContent":that.isMatch,
			  "teacherId":that.courseData.courseTeacherId
    	}).then(function(response){
    		if(val=='自习'){
    			  if(response.data.length!=0){
    						that.$parent.showToast('提交成功')
    				}
    			 	
    		}else if(val=='停课'){
    				if(response.data.length!=0){
    						that.$parent.showToast('提交成功')
    				}
    			
    		}else if(val=='正常'){
    				if(response.data.length!=0){
    					that.$parent.showToast('提交成功')
    				}else{
    					that.$parent.showToast('提交失败')
    				}
    		}
//  		console.info(response.data)
    		if(response.data==1){
    			 that.diaryState=response.data
    		}else if(response.data==2){
    			 that.diaryState=response.data
    			 that.isEditSec=false
    		}else if(response.data=='已修改，无法再次修改'){
    			 
    		}
    		
    	}).catch(function(error){
    		that.$parent.showToast('提交失败')
    	})
    },
//	getClassDiary(){
//		let that=this
//		that.axios.get('/iyx/diary/ClassInfo/'+localStorage.classId+'?token='+localStorage.token).then(function(response){
//		}).catch(function(error){
//		})
//	},
    tiaotingkeHandle(){
      let val = this.ttklx
      if(val == 'ceaseClass'){
        this.ceaseClassFn()
      }
      if(val == 'tiaoke'){
        this.tiaokeFn()
      }
      if(val == 'zengke'){
        this.zengkeFn()
      }
      if(val == 'zixi'){
        this.zixiFn()
      }
    },
    handleChange(val){
    	if(val=='save'){
    		if(this.isEditSec==true){
    			 this.submitThis()
    		}else if(this.isEditSec==false){
    			 this.popIsTime=true
					 this.popIsTimeTitle='您已修改，无法再次修改'
    		}
    		
    	}else if(val=='edit'){
        this.enable=true
      }else{
    		this.dialog=true
    	}
    },
    ceaseClassFn(){
    	this.open()
    	this.isCeaseClass=true
    	this.popTitleInfo='确定要停课？'
    },
    zixiFn(){
      this.open()
      this.isZixi=true
      this.popTitleInfo='确定要自习？'
    },
    submitThis(){
    	var arrTimeMinute=0
    	var leaTimeMinute=0
    	var arrT=this.arrTime+''
    	var leaT=this.leaTime+''
    	if(arrT.length==3){
    		arrTimeMinute=parseInt(arrT.slice(0,1))*60+parseInt(arrT.slice(1,3))
    	}else{
    		arrTimeMinute=parseInt(arrT.slice(0,2))*60+parseInt(arrT.slice(2,4))
    	}
    	if(leaT.length==3){
    		leaTimeMinute=parseInt(leaT.slice(0,1))*60+parseInt(leaT.slice(1,3))
    	}else{
    		leaTimeMinute=parseInt(leaT.slice(0,2))*60+parseInt(leaT.slice(2,4))
    	}
    	var timeD=leaTimeMinute-arrTimeMinute
    	
    	
    	if(this.teachTypeSub.length==0){
    			this.popIsTime=true
					this.popIsTimeTitle='请选择授课类型'
    	}else{
    		  if(this.arrTime<=this.leaTime){
		    			if(timeD<=(this.JSSJ+20)){
						    	if(this.showContent.length==0){
						    			this.popIsTime=true
											this.popIsTimeTitle='请填写授课内容'
						    	}else{
						    		  this.open()
							    	  this.isSubmitThis=true
							    	  this.popTitleInfo='确定要提交吗？'
						    	}
		    			}else{
		    					this.popIsTime=true
									this.popIsTimeTitle='时间差不得大于最大授课时长'
		    			}
					}else{
								this.popIsTime=true
								this.popIsTimeTitle='离开时间不得早于到达时间'
					}
    	}
    	
    	
    	
    },
    open () {
      this.popCommissary = true
    },
    close (val) {
    	if(val=='sure'){
    					
			    		if(this.isSubmitThis){
		//	    			this.save("正常")
									this.save2("正常")
			      		this.isSubmitThis=false
			    		}
		          if(this.isZixi){
		            this.save2("自习")
		            this.dialog=false
		            this.isZixi=false
		          }
			      	if(this.isCeaseClass){
			      		this.save2("停课")
			      		this.dialog=false
			      		this.isCeaseClass=false
			      	}else{
			      	}
			      	this.popCommissary = false
      }else if(val=='cancel'){
      	this.popCommissary = false
      }else if(val=='add'){
      	this.popIsAdd=false
      }else if(val=='TimeCorrect'){
      	this.popIsTime=false
      }
//    this.toastTimer = setTimeout(() => { 
//      this.$router.push({
//        path: 'index'
//      })
//    }, 1000)
      
    },
    tiaokeFn() {
      let that = this
      this.$router.push({
        path: 'ttk',
//      query: this.ktxq
				query:this.courseData
      })
    },
    zengkeFn(v) {
    	if(this.todayCourse.length==undefined){
    		var course_index=[]
    		
    		this.$router.push({
	        name: 'zk',
	        query:course_index
	      })
    	}
      if(this.todayCourse.length<6){

      	var course_index=[]
	  		for(var i in this.todayCourse){
	  			course_index.push(this.todayCourse[i].courseWhichIndex)
	  		}
      	
      	this.$router.push({
	        name: 'zk',
	        query:course_index
	      })
      }else{
      	this.popIsAdd=true
      	this.popIsAddTitle='今天课程已满'
      }
      
    },
    prev(){
      let that=this
      if(that.sknrIndex>=0){
        that.sknrIndex=that.sknrIndex-1
      }
    },
    next(){
      let that=this
      if(that.sknrIndex<that.sknrList.length-1){
        that.sknrIndex=that.sknrIndex+1
      }
    },
    handleToggle (key) {//为什么switch不用调这个方法，因为不需要实时提交数据，区别于点名
      if(!this.disable){
        this[key] = !this[key]
      }
    },
    hasClass(val){
      this.noClass = !val
      this.isbotBtn = val
    },
    changeXkkh(ktxq,allParameters){
      const that = this
      that.sknrIndex = -1
      that.nrbm=ktxq.NRBM
      that.allParameters = allParameters
      that.ktxq = ktxq
      axios.get('/gleenSoft-base/jxkh/xxwypj/query?NRBM='+ktxq.NRBM).then(function (response) {
          let sb=response.data.result
          if(sb!=null){
            that.saveType='update'
            that.DDSJ=sb.DDSJ
            that.LKSJ=sb.LKSJ
            that.JSSJ=sb.JSSJ
            that.SFKQ=sb.SFKQ==1
            that.SFTG=sb.SFTG==1
            that.ZYBZ=sb.ZYBZ==1
            that.enable= false
          }else{
            that.saveType='save'
            that.DDSJ=allParameters[ktxq.DJJ+'_class_start']
            that.LKSJ=allParameters[(parseInt(ktxq.DJJ)-1+parseInt(ktxq.SKCD))+'_class_end']
            that.SKSC=parseInt(ktxq.SKCD)*45;
            that.JSSJ=45
            that.SFKQ=true
            that.SFTG=true
            that.ZYBZ=true
            that.enable= true
          }
          axios.get('/gleenSoft-base/jxkh/xxwypj/nrList', {
          params: {
            NRBM: ktxq.NRBM
          }
        }).then(function (response) {
          that.sknrList=response.data.nrList 
          if(that.sknrList.length>0){
            //that.sknrIndex=that.sknrList.length-1
            that.sknrIndex = parseInt(ktxq.NRBM.substring(50))-1
          }
        }).catch(function (error) {
          console.log(error)
        });
      })
      .catch(function (error) {
        console.log(error)
      });
    },save(sklx){
      let that= this;
      axios.post('/gleenSoft-base/jxkh/xxwypj/'+that.saveType,{
        NRBM:that.nrbm,
        SFTG:that.SFTG?1:0, //是否脱岗
        DDSJ:that.DDSJ, //到达时间
        LKSJ:that.LKSJ, //离开时间
        JSSJ:that.JSSJ, //讲授时间
        ZYBZ:that.ZYBZ?1:0, //作业布置
        SFKQ:that.SFKQ?1:0,  //是否考勤
        SKLX: sklx,
        SJNRBH:that.sknrIndex>-1?that.sknrList[that.sknrIndex]["NRBM"]:''
      }).then(function (response) {
        that.enable=false
      }).catch(function (error) {
      })
      this.toast = true
      if (this.toastTimer) clearTimeout(this.toastTimer)
      this.toastTimer = setTimeout(() => { this.toast = false }, 1000)
    }
  }
 
}
</script>
<style>
.diary-title{
 	height: 3rem;
 	display: flex;
 	align-items: center; 
 	background-color: #f5f5f5;
 	justify-content: space-between;
}
.diary-title-left{
	margin-left: 5%;
	color: #8a8a8a;
	font-size: 0.9rem;
}
.diary_state{
	padding: 2px 4px;
	float: right;
	margin-right: 8%;
	border-radius: 3px;
	color: #fff;
	display: block;
	font-size: 12px;
}
.diary_unsubmit{
	background-color: #f83535;
}
.diary_submit{
	background-color: rgb(60, 159, 236);
}
.diary_edit{
	background-color: rgb(76, 231, 98);
}
.Edit-count{
	position: absolute;
	right: 1rem; 
	bottom: 0.2rem;
	font-size: 0.8rem;
}
.defaultLine{
		border-bottom: 1px solid rgba(0,0,0,.12)!important;	
}
.temp-mask{
	 z-index: 1501;
	 background-color:rgba(0,0,0,0);
	 position: fixed;
	 width: 100%;
	 height: 100%;
	 left: 0;
	 top: 0;
}
.picker-slot-wrapper{
	transition-duration:1s!important;
	transition-timing-function:cubic-bezier(0.2,0.1,0.35,1)!important!important
}
.yd-popup-show{
		height: auto!important;
}
.slot1{
	font-size: 1rem;
}
.mu-picker-item{
	font-size: 1rem!important;
}
.slider-time{
		display: flex; 
		height: 2.6rem; 
		border-bottom: 1px solid #f2f2f2;
		-webkit-box-pack: justify;
		justify-content: space-between;
		position: relative;
}
.slider-time a{
	font-size: 0.9rem;
	display: flex;
	align-items: center;
	padding: 0 30px;
}
.demo-popup-bottom{
	width: 100%;
}
 .mu-content-block{
 		padding: 0!important;
 }
	.demo-picker-container{
		width: 100%;
		/*position: absolute;*/
		z-index: 320;
		/*left: 0;*/
		/*bottom: 0;*/
		background-color: white;
	}
  .mu-sub-header{
    font-size:20px;
    background-color:whitesmoke;
  }
  .topSelectBtn{
    background-color: blue;
    color:white;
  }
  .mu-list-item-zzg{
    padding:20px;
  }
  .yd-datetime-input{
  	position: absolute;
  	left: 0;
  	top: 0;
  	width: 100%;
  	height: 100%;
  	z-index: 250;
  	color:rgba(0,0,0,0);
  }
  .yd-datetime-head{
  	background-color: #fff;
  }
  .yd-datetime-head>a:last-child{
		color: #2397f2!important;
	}
.mt8 {
  margin-top: 8px;
  margin-bottom: 1.5rem;
}
.flex-demo {
  text-align: center;
}
.flex-title{
  text-size:18px;
  background-color: #eee;
  padding:10px;
}
.flex-body{
  padding: 10px;
  background-color: #fff;
}
.bottom-btnbar{
    position: fixed !important;
    right: 0;
    bottom: 0;
    width: auto;
    -webkit-transition: all .45s cubic-bezier(.23,1,.32,1);
    transition: all .45s cubic-bezier(.23,1,.32,1);
    background-color: white;
    border-top:1px solid #eee;
    z-index: 280;
  }
  .active{
  	background-color:rgba(255,255,255,0)!important;
  	color:#ff4081!important;
  }
</style>